import numpy as np
import cv2 as cv

cap = cv.VideoCapture('d5.mp4')
while cap.isOpened():
    ret, frame = cap.read()
    if not ret:
        print('can not read frame, exiting')
        break

    gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)
    cv.imshow('frame', gray)
    if cv.waitKey(40) == ord('q'):
        break

cap.release()
cv.destroyAllWindows()